package cc.rengu.redp.system.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;

@Validated
@Controller
@RequestMapping("/ssologin")
public class SSOLoginController {
    @CrossOrigin(value="http://127.0.0.1:8081",maxAge=1800,allowedHeaders="*")
    @RequestMapping(value = "",method = RequestMethod.POST)
    public String ssoLogin(Model model, HttpServletRequest request, RedirectAttributes attributes) {
        String username = request.getParameter("username");
        String userpwd = request.getParameter("password");
        attributes.addAttribute("username",username);
        attributes.addAttribute("userpwd",userpwd);
        return "redirect:http://127.0.0.1:8081/";
    }
}
